const { ref } = Vue
import { useFetch } from '../../../Scripts/hooks/useFetch.js'

export function useUnCheckContainer() {
  const unCheckContainerData = ref([]);
  const unCheckContainerCount = ref(0);
  const unCheckDetailList = ref(null);
  const unCheckDetailListRef = ref(null);

  const getUnCheckContainerDataList = async configObj => {
    const { data } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        ...configObj,
        type: `${configObj.method}`,
        factoryid: configObj.factoryid,
        workerid: configObj.workerid
      }
    });
    unCheckContainerData.value = data.value;
    unCheckContainerCount.value = data.value.length;
  }

  const getUnCheckDetailsList = async configObj => {
    const { data, status: { code, msg } } = await useFetch({
      url: `${configObj.url}?actions=${configObj.method}`,
      data: {
        ...configObj,
        type: `${configObj.method}`
      }
    });
    unCheckDetailList.value = data.value;
    return data.value;
  }

  return {
    unCheckContainerData, unCheckContainerCount, unCheckDetailList, unCheckDetailListRef,
    getUnCheckContainerDataList, getUnCheckDetailsList
  }
}